import 'package:json_annotation/json_annotation.dart';

part 'heart_rate_model.g.dart';

/// 心率记录模型
@JsonSerializable()
class HeartRateRecord {
  @JsonKey(name: 'id')
  final int? id;
  
  @JsonKey(name: 'deviceSn')
  final String? deviceSn;
  
  @JsonKey(name: 'dailyValue')
  final String? dailyValue;
  
  @JsonKey(name: 'heartRate')
  final int? heartRate;
  
  @JsonKey(name: 'endTime')
  final String? endTime;
  
  @JsonKey(name: 'createTime')
  final String? createTime;
  
  @JsonKey(name: 'updateTime')
  final String? updateTime;

  HeartRateRecord({
    this.id,
    this.deviceSn,
    this.dailyValue,
    this.heartRate,
    this.endTime,
    this.createTime,
    this.updateTime,
  });

  factory HeartRateRecord.fromJson(Map<String, dynamic> json) => _$HeartRateRecordFromJson(json);
  Map<String, dynamic> toJson() => _$HeartRateRecordToJson(this);
}

/// 心率API响应模型
@JsonSerializable()
class HeartRateResponse {
  @JsonKey(name: 'msg')
  final String? msg;
  
  @JsonKey(name: 'code')
  final int? code;
  
  @JsonKey(name: 'data')
  final HeartRateData? data;

  HeartRateResponse({
    this.msg,
    this.code,
    this.data,
  });

  factory HeartRateResponse.fromJson(Map<String, dynamic> json) => _$HeartRateResponseFromJson(json);
  Map<String, dynamic> toJson() => _$HeartRateResponseToJson(this);
}

/// 心率数据模型
@JsonSerializable()
class HeartRateData {
  @JsonKey(name: 'deviceSn')
  final String? deviceSn;
  
  @JsonKey(name: 'dailyValue')
  final String? dailyValue;
  
  @JsonKey(name: 'heartRate')
  final int? heartRate;
  
  @JsonKey(name: 'heartRateList')
  final List<HeartRateRecord>? heartRateList;
  
  @JsonKey(name: 'endTime')
  final String? endTime;

  HeartRateData({
    this.deviceSn,
    this.dailyValue,
    this.heartRate,
    this.heartRateList,
    this.endTime,
  });

  factory HeartRateData.fromJson(Map<String, dynamic> json) => _$HeartRateDataFromJson(json);
  Map<String, dynamic> toJson() => _$HeartRateDataToJson(this);
}

/// 心率列表API响应模型
@JsonSerializable()
class HeartRateListResponse {
  @JsonKey(name: 'msg')
  final String? msg;
  
  @JsonKey(name: 'code')
  final int? code;
  
  @JsonKey(name: 'data')
  final List<HeartRateRecord>? data;

  HeartRateListResponse({
    this.msg,
    this.code,
    this.data,
  });

  factory HeartRateListResponse.fromJson(Map<String, dynamic> json) => _$HeartRateListResponseFromJson(json);
  Map<String, dynamic> toJson() => _$HeartRateListResponseToJson(this);
}
